package org.yuanqiframework.yuanqi.boot.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.yuanqiframework.yuanqi.boot.sys.dto.SysWebsiteDTO;
import org.yuanqiframework.yuanqi.boot.sys.entity.SysWebsite;
import org.yuanqiframework.yuanqi.boot.sys.mapper.SysWebsiteMapper;
import org.yuanqiframework.yuanqi.boot.sys.service.SysWebsiteService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cbt28
 * @description 针对表【sys_website】的数据库操作Service实现
 * @createDate 2025-07-19 15:43:57
 */
@Service
public class SysWebsiteServiceImpl extends ServiceImpl<SysWebsiteMapper, SysWebsite>
        implements SysWebsiteService {
    @Resource
    private SysWebsiteMapper sysWebsiteMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean websiteSyncBatch(List<SysWebsiteDTO> sysWebsiteDTOList) {
        sysWebsiteDTOList.forEach(sysWebsiteDTO -> {
            this.update(new LambdaUpdateWrapper<SysWebsite>()
                    .set(SysWebsite::getSettingValue, sysWebsiteDTO.getSettingValue())
                    .eq(SysWebsite::getKeyName, sysWebsiteDTO.getKeyName()));
        });
        return true;
    }
}




